//
//  JBBasicDataListViewModuleController.m
//  DataViewModuleController
//
//  Created by Yongbin Zhang on 12/30/13.
//  Copyright (c) 2013 JustBen. All rights reserved.
//

#import "JBBasicDataListViewModuleController.h"


@interface JBBasicDataListViewModuleController ()


@end

@implementation JBBasicDataListViewModuleController

- (id)init
{
    self = [super init];
    if (self) {
        _dataList = [[NSMutableArray alloc] init];
        self.data = _dataList;
        
        _loadCount = 12;
        _lastPos = @"0";
    }
    
    return self;
}



//  模版方法
//  重新加载数据
- (void)reloadData
{
    [self reloadDataWithSuccess:nil failure:nil];
}

- (void)reloadDataWithSuccess:(void (^)())success failure:(void (^)(NSInteger errorCode, NSString *errorMsg))failure
{
    [super loadDataWithSuccess:success failure:failure];
}

- (void)reloadDataSuccessedWithLastPos:(NSString *)lastPos dataList:(NSArray *)dataList
{
    self.lastPos = lastPos;
    
    [self.dataList removeAllObjects];
    [self.dataList addObjectsFromArray:dataList];
    
    [super loadDataSuccessedWithData:dataList];
}

- (void)reloadDataFailed
{
    [super loadDataFailed];
}



//  模版方法
//  加载更多的数据
- (void)loadMoreData
{
    [self loadMoreDataWithSuccess:nil failure:nil];
}

- (void)loadMoreDataWithSuccess:(void (^)())success failure:(void (^)(NSInteger errorCode, NSString *errorMsg))failure
{
    [super loadDataWithSuccess:success failure:failure];
}

- (void)loadMoreDataSuccessedWithLastPos:(NSString *)lastPos dataList:(NSArray *)dataList
{
    self.lastPos = lastPos;
    
    if (dataList && dataList.count > 0) {
        [self.dataList addObjectsFromArray:dataList];
    }
    
    [super loadDataSuccessedWithData:dataList];
}

- (void)loadMoreDataFailed
{
    [super loadDataFailed];
}


@end
